#define _CRT_SECURE_NO_WARNINGS 1
#include <stdio.h>

int minSwaps(int arr[], int n) {
    int cnt0 = 0, cnt1 = 0, swap0 = 0, swap1 = 0;

    for (int i = 0; i < n; i++) {
        if (arr[i] == 0) {
            cnt0++;
            swap0 += cnt1;
        }
        else {
            cnt1++;
            swap1 += cnt0;
        }
    }

    return (cnt0 < cnt1) ? swap0 : swap1;
}

int main() {
    int n;
    scanf("%d", &n);
    int arr[200000];
    for (int i = 0; i < n * 2; i++) {
        scanf("%d", &arr[i]);
    }
    int result = minSwaps(arr, n * 2);
    printf("%d", result);
    return 0;
}
